<template>
  <div>
    <h3>App1 模块</h3>
    <router-link to="/">Home</router-link>
    &nbsp;&nbsp;|&nbsp;&nbsp;
    <router-link to="/about">About</router-link>
    <router-view />


    <button @click="setData()">setData</button>
    <button @click="getData()">getData</button>
    <iframe src="http://10.10.36.138:3002/index.html" frameborder="0" id="ifrCommon"></iframe>
  </div>
</template>

<script>
export default {
  data () {
    return {}
  },
  mounted () {
    console.log(this)
    console.log(this.$router)
  },
  methods:{
    handleMsg(){
      window.addEventListener('message', function(event){
        console.log('parent page', event)
      })
    },
    setData(){
      document.getElementById('ifrCommon').contentWindow.postMessage({
        fn: 'setData',
        param: {
          name: {
            first: 'zhang',
            last: 'san'
          }
        }
      }, '*')
    },
    getData(){
      var result = document.getElementById('ifrCommon').contentWindow.postMessage({
        fn: 'getData',
        param: {
          key: 'name'
        }
      }, '*')

      console.debug('getData result', result);
    }
  }
}

</script>
